import cv2
import rgy
import DirectionControl


def color():
#if __name__ == '__main__':
    video_full_path = "http://192.168.137.2:8081/"
    cap = cv2.VideoCapture(video_full_path)
    #cap = cv2.VideoCapture(0)
    success = cap.isOpened()
    print(success)

    print("请输入你要识别的颜色，1表示黄色，2表示绿色，3表示红色")
    flag = input()

    print(flag)
    index = 0
    while (success):
        index = index + 1
        success, frame = cap.read()

        if index % 10 == 0:  # 按下s键，进入下面的保存图片操作
            cv2.imwrite("./pic/" + str(index / 10) + ".jpg", frame)
            print("save" + str(index / 10) + ".jpg successfuly!")
            print("-------------------------")
            data = rgy.fuction(frame, flag)
            DirectionControl.ROVDirectionControl(data)

    # #测试用例
    # frame = cv2.imread('./pic/50.0.jpg')
    # data = rgy.fuction(frame,'1')
    # DirectionControl.ROVDirectionControl(data)
